package com.msmall.community.play.service;

import java.util.List;

import com.msmall.base.pager.PaginationSupport;
import com.msmall.base.service.BaseManager;
import com.msmall.community.play.model.Play;

public interface PlayManager extends BaseManager<Play, Long>{

	public void savePlay(Play play, Long creator);
	
	// 获得用户所具有 的所有组件
	public List<Play> getByUserid(Long userid) throws Exception ;
	
	/**
	 * 先从缓存获得，如果为NULL，查询数据库
	 */
	public Play getPlay(Long playId)throws Exception;
	/**
	 * 查询数据库
	 * @param playId
	 * @return
	 */
	public Play loadPlay(Long playId)throws Exception;
	/**
	 * 先从缓存获得，如果为NULL，重新查询数据库
	 */
	public List<Play> getAllPlays() throws Exception;
	/**
	 * 获得所有有效的PLAY
	 * @param page
	 * @throws Exception
	 */
	public void getAvaliablePlays(PaginationSupport page) throws Exception;
	
	/**
	 * 用户加入PLAY 首先检查是否已经加入了，如果已经加入返回FALSE
	 * @param userid
	 * @param playId
	 * @return
	 * @throws Exception
	 */
	public boolean joinPlay(Long userid, Long playId) throws Exception;
	
	/**
	 * 用户删除已经加入的Play
	 * @param userid
	 * @param playId
	 * @return
	 * @throws Exception
	 */
	public boolean leavePlay(Long userid, Long playId) throws Exception;
	
}
